package j04zuoye;

import java.util.*;

public class J2 {
    public static void main(String[] args) {
        HashMap<String,String> map1 = new HashMap<>();
        map1.put("join","html");
        map1.put("lucy","javase");

        Set<Map.Entry<String,String>> entrySet = map1.entrySet();
        for (Map.Entry<String, String> entry :
                entrySet) {
            System.out.println(entry.getKey()+"="+entry.getValue());
        }
    }
}

class J3Set{
    public static void main(String[] args) {
//        Set<Integer> arr1 = new HashSet<>();
        Set<Integer> arr1 = new TreeSet<>((num1,num2)->num2-num1);
        Random r = new Random();
        while (true){
            arr1.add(r.nextInt(11)+10);
            if(arr1.size()==8){
                break;
            }
        }
        System.out.println("arr1 = " + arr1);
    }
}

class Man{
    String name;
    int age;
    int height;

    public Man(String name, int age, int height) {
        this.name = name;
        this.age = age;
        this.height = height;
    }

    @Override
    public String toString() {
        return "Man{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", height=" + height +
                '}';
    }
}

class ManTest{
    public static void main(String[] args) {
        List<Man> arr = new ArrayList<>();
        arr.add(new Man("jack",20,170));
        arr.add(new Man("lucy",19,167));
        arr.add(new Man("hanmeimei",78,147));
        arr.add(new Man("mack",20,185));
        arr.add(new Man("lilei",12,150));
        arr.add(new Man("jim",20,165));
        System.out.println(arr);
        //age
        arr.sort((man1,man2)->man1.age-man2.age);
        System.out.println(arr);
        //age , height
        arr.sort((man1,man2)->{
            if(man1.age!=man2.age){
                return man1.age-man2.age;
            }
            //height
//            return man1.height-man2.height;
            return man2.height-man1.height;
        });
        System.out.println("=====");
        System.out.println(arr);
    }
}